<script setup>
import {ref} from "vue";
import request5151 from "../../../utils/request5151.js";
import {ElMessage} from "element-plus";
//loading
const loading = ref(true)
//分页
let pageNum = 1
let pageSize = 3
const total = ref(0)
const handleSizeChange = (val) => {
  pageSize = val
  getOrdersData()
}
const handleCurrentChange = (val) => {
  pageNum = val
  getOrdersData()
}
//搜索
const searchData = ref({
  sNumber: '',
  payStatus: ''
})
//重置
const reset = () => {
  searchData.value = {
    sNumber: '',
    payStatus: ''
  }
}
//订单数据
const ordersData = ref()
//获取订单数据
const getOrdersData = () => {
  request5151({
    url: '/order/pageSelectAll',
    method: 'get',
    params: {
      pageNum: pageNum,
      pageSize: pageSize,
      sNumber: searchData.value.sNumber ? searchData.value.sNumber : null,
      payStatus: searchData.value.payStatus ? searchData.value.payStatus : null,
    }
  }).then((res) => {
    ordersData.value = res.data.data.records
    loading.value = false
  }).catch(() => {
    ElMessage.error('请求失败')
    loading.value = false
  })
}
getOrdersData()
</script>

<template>
  <div class="myorderAll">
    <!--面包屑-->
    <el-breadcrumb separator="/" style="margin-bottom: 20px;">
      <el-breadcrumb-item><b>迎新信息管理</b></el-breadcrumb-item>
      <el-breadcrumb-item>缴费管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!--搜索-->
    <el-form :inline="true" :model="searchData" class="demo-form-inline">
      <el-form-item label="学号">
        <el-input v-model="searchData.sNumber" placeholder="输入学号"/>
      </el-form-item>
      <el-form-item label="状态">
        <el-select
            v-model="searchData.payStatus"
            placeholder="输入状态"
            clearable
            style="width: 120px;"
        >
          <el-option label="待支付" value="待支付"/>
          <el-option label="已支付" value="已支付"/>
        </el-select>
      </el-form-item>
      <el-button type="danger" @click="reset" style="margin-bottom: 20px;">重置</el-button>
      <el-button type="success" @click="getOrdersData" style="margin-bottom: 20px;">查询</el-button>
    </el-form>
    <!--数据-->
    <el-table :data="ordersData" style="width: 100%" v-loading="loading"
              empty-text="暂无数据" element-loading-text="数据加载中...">
      <el-table-column prop="orderId" label="订单编号" width="120"/>
      <el-table-column prop="snumber" label="学号" width="110"/>
      <el-table-column prop="liveCost" label="生活费" width="100"/>
      <el-table-column prop="studyCost" label="学费" width="100"/>
      <el-table-column prop="otherCost" label="其他费用" width="100"/>
      <el-table-column prop="name" label="费用项" width="160"/>
      <el-table-column prop="payNo" label="支付单号" width="200"/>
      <el-table-column prop="payTime" label="支付时间" width="200"/>
      <el-table-column prop="total" label="总金额" width="100"/>
      <el-table-column prop="payStatus" label="状态" width="90">
        <template #default="scope">
          <el-tag v-if="scope.row.payStatus === '已支付'" type="success">{{ scope.row.payStatus }}</el-tag>
          <el-tag v-else type="danger">{{ scope.row.payStatus }}</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background layout="prev,sizes, pager, next"
                   :page-sizes="[2,5]"
                   :total="total"
                   :page-size="pageSize"
                   @size-change="handleSizeChange"
                   @current-change="handleCurrentChange"

    />
  </div>
</template>

<style scoped>

</style>
